// var myModalLabel = $('#myModalLabel');
// console.log(myModalLabel);
// var btnlogin = $('.btn-default');
var loginlink = $('.loginlink');
// var classname = $('#classname');
var remark = $('#remark');
// var relogin = $('.relogin');
if(JSON.stringify($.cookie())=='{}'){  //本地是否有cookie
    console.log('本地无cookie');
}else{
    console.log('本地有cookie');
    var cookiename=document.cookie.split(";")[0].split("=")[0];
    for(var key in $.cookie()){
        // console.log(i)
        cookiename=key;
    }
    create1();
    create2();
}
loginlink.on('click',function(){  //页面登录链接
    $('#username').val(null);
    $('#password').val(null);
});
$('#abc').on('click',function(){  //确认登录
    var username = $('#username').val();
    var password = $('#password').val();
    login(username,password);
    console.log(yesorno);
})
async function login(name,pass){  //接收数据
    var data = await Ajax('POST', 'http://39.105.192.164:9090/apitest/login', `username=${name}&password=${pass}`);
    if(JSON.parse(data).code == 1){  //判断是否链接成功
        var yesorno = $('#yesorno').prop('checked');
        if(yesorno==true){  //判定是否记住密码
            $.cookie(`${name}`,`${pass}`,{ expires: 7 })  //存入cookie
        }else{
            $.cookie(`${name}`,`${pass}`)  //存入cookie
        }
        window.location.reload();
    }else{
        alert('账号密码错误')
    }
}
